//
//  WSGAllCell.m
//  oneDollar
//
//  Created by Laki on 16/6/17.
//  Copyright © 2016年 com.Laki.corder. All rights reserved.
//

#import "WSGAllCell.h"
#import "WSGAllItem.h"

#import <UIImageView+WebCache.h>

@interface WSGAllCell()
/** 商品名称*/
@property (weak, nonatomic) IBOutlet UILabel *productNameLabel;
/** 商品图片*/
@property (weak, nonatomic) IBOutlet UIImageView *productUrlImage;
/** 总需求数*/
@property (weak, nonatomic) IBOutlet UILabel *totalTimesLabel;
/** 剩余数*/
@property (weak, nonatomic) IBOutlet UILabel *remainTimesLabel;
/** 进度条*/
@property (weak, nonatomic) IBOutlet UIProgressView *progress;

@end

@implementation WSGAllCell

/*
 * 根据模型设置数据
 */
- (void)setAllItem:(WSGAllItem *)allItem{
    _allItem = allItem;
    // 设置商品名称
    self.productNameLabel.text = allItem.productName;
    // 设置总需求数
    self.totalTimesLabel.text = allItem.totalTimes;
    // 设置剩余数
    self.remainTimesLabel.text = allItem.remainTimes;
    
    // 换算
    CGFloat remainTimes = [allItem.remainTimes doubleValue];
    CGFloat totalTimes = [allItem.totalTimes doubleValue];
    
    // 设置进度条
    self.progress.progress = 1.0 - (remainTimes / totalTimes);
    
    // 设置商品图片
    [self.productUrlImage sd_setImageWithURL:[NSURL URLWithString:allItem.productUrl] placeholderImage:[UIImage imageNamed:@"Circle_BackgroundBigImage"]];
}

@end
